/*******************************************************************************\
** cinemagraph:SketchBookViewController.m
** Created by CZ(cz.devnet@gmail.com) on 11/3/16
**
**  Copyright © 2016 projm. All rights reserved.
\*******************************************************************************/


#import "SketchBookViewController.h"
#import "FloatCameraView.h"
#import "CameraViewController.h"

#import <Masonry/Masonry.h>

@interface SketchBookViewController ()
@property (strong, nonatomic) FloatCameraView *cameraView;
@property (strong, nonatomic) UIButton *cameraBtn;
@end

@implementation SketchBookViewController



- (instancetype) init {
    if (self = [super init]) {
        [self.view setBackgroundColor:[UIColor whiteColor]];
        self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"画簿" image:[UIImage imageNamed:@"picture"] selectedImage:[UIImage imageNamed:@"picture"]];
    }
    return self;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction) onCamearClicked: (id) sender {
    NSLog(@"onCamera");
    CameraViewController *cameraVC = [[CameraViewController alloc] init];
    if (nil == cameraVC) {
        NSLog(@"create camera VC error");
        return ;
    }
    [self presentViewController:cameraVC animated:YES completion:^{
        NSLog(@"present camera viewcontroller!");
    }];
}

- (void ) layoutUI {
    UIImage *btnBg = [UIImage imageNamed:@"sketchbook_camera"];
    _cameraBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_cameraBtn setImage:btnBg forState:UIControlStateNormal];
    [_cameraBtn addTarget:self action:@selector(onCamearClicked:) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:_cameraBtn];
    
    [_cameraBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@50);
        make.height.equalTo(@50);
        make.right.equalTo(self.view.mas_right);
        make.bottom.equalTo(self.view.mas_bottom).offset(-100);
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self layoutUI];
}


@end
